import React, { Component } from "react";
import Recommend from './components/Recommend';
import List from './components/List';
import Topic from './components/Topic';
import Writer from './components/Writer';
import { HomeWrapper, HomeLeft, HomeRight} from './style';
import * as methods from './store/actionCreators';
import {connect} from "react-redux";

class Home extends Component {
    componentDidMount() {
        this.props.getAsyncHomeData();
    }
    render() {
        return (
            <HomeWrapper>
                <HomeLeft>
                    <img className='bannerImage' src="//upload.jianshu.io/admin_banners/web_images/4675/569882aa7e239c755c754c4d170a859eca26f752.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/1250/h/540" alt=""/>
                    <Topic />
                    <List />
                </HomeLeft>
                <HomeRight>
                    <Recommend />
                    <Writer />
                </HomeRight>
            </HomeWrapper>
        )
    }
}

const mapDispatch = (dispatch) => ({
    getAsyncHomeData() {
        dispatch(methods.asyncHomeData())
    }
});

export default connect(null,mapDispatch)(Home);